var express = require('express');
var router = express.Router();
var request = require('../util/http_request.js');


/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

/**
获取股票信息
*/
router.get('/gupiao',function (req, res, next) {
	request('/gjpzhangwu/select_all','GET',{})
	.then(function (data) {
		res.render('gupiao',{data:JSON.parse(data)});
	});
});

router.get('/add_gupian',function (req, res, next) {
	res.render('add_gupian',{});
});


router.post('/add_gupiao/handler',function (req, res, next) {
	request('/add_gupiao/handler','POST',req.body)
	.then(function (data) {
		data = JSON.parse(data);
		if(data.status==1){
			res.redirect("/gupiao");
		}else{
			res.send(data.msg);
		}
	});
});
module.exports = router;
